#ifndef __EXTERNAL_FACTORY_INTERFACE__
#define __EXTERNAL_FACTORY_INTERFACE__

#ifdef WIN32
	#ifdef __cplusplus
		#define EXPORT_MACRO extern "C" __declspec(dllexport)
	#else
		#define EXPORT_MACRO __declspec(dllexport)
	#endif
#else
	#ifdef __cplusplus
		#define EXPORT_MACRO extern "C"
	#else
		#define EXPORT_MACRO
	#endif
#endif

//Function return values
#define FACT_SUCCESS					0
#define FACT_ERR_NO_PREFERENCES_FILE	-1

//interface version info (not to be modified)
#define FACT_INTERFACE_MAJOR_VERSION	0x01
#define FACT_INTERFACE_MINOR_VERSION	0x00
#define FACT_INTERFACE_SUB_VERSION		0x00

//size of string passed into function (not to be modified)
#define FACT_PREF_FILE_BUFF_SIZE	128

/* This function should not be modified */
EXPORT_MACRO int GETFACTINTERFACEVERSION() 
{ 
	return (FACT_INTERFACE_MAJOR_VERSION << 16 | FACT_INTERFACE_MINOR_VERSION << 8 | FACT_INTERFACE_SUB_VERSION); 
}

//functions to be implemented...

/* This function should be used to specify the preference file (if required) used with this external factory */
EXPORT_MACRO void GETFACTPREFERENCEFILE(char caPrefFile[FACT_PREF_FILE_BUFF_SIZE]);

/*
	The purpose of this function is to create particles and pass them back to EDEM for addition to 
	the simulation. EDEM does not perform any checks on the validity of the particles position, 
	velocity etc. It is recommended that you ensure that you particle cannot be overlapping an existing
	particle.

	This function only creates 1 particle at a time. To create more than 1 in a time step, set 
	bMoreToCreate to 1. When you finish creating particles, set it to 0.

	The following parameters are passed in to this function and should not be altered by the user:

		sPrefFile	- name & location of the optional preferences file
		nTime		- this is the current time the simulation is at

	The following parameters should be set by the user:

		bCreated - set as 1 if a particle was created in this time step, otherwise 0
		name     - this is the name of the particle template from which you are creating your particle.
					This must match <i>exactly</i> (including capitalisation).
		nSize    - a multiplication factor from the size of the template particle. nSize = 1 means that
					this particle will have exactly the same dimensions as the template.

		nPosX,Y,Z			- the x, y, z coordinates of the new particle
		nVelX,Y,Z			- the x, y, z components of the velocity of the new particle
		nOrientXX,XY,...,ZZ - the elements in the orientation matrix. This is a cosine matrix representing
								deviations from x,y,z. The user must ensure that this matrix is orthogonal.
		nAngVelX,Y,Z		- the x, y, z components of the angular velocity of the new particle
		bMoreToCreate		- set this as 1 if you wish to create more particles, otherwise set as 0

	The function should return a value to indicate success or failure (see error codes defined above).
	
	For more information see the help or one of the examples shipped with the product.
*/
EXPORT_MACRO int CREATEPARTICLE(const char *sPrefFile, double *nTime, int *bCreated, char *name, double *nSize, 
                                 double *nPosX, double *nPosY, double *nPosZ,
                                 double *nVelX, double *nVelY, double *nVelZ, 
                                 double *nOrientXX, double *nOrientXY, double *nOrientXZ,
                                 double *nOrientYX, double *nOrientYY, double *nOrientYZ, 
                                 double *nOrientZX, double *nOrientZY, double *nOrientZZ,
                                 double *nAngVelX, double *nAngVelY, double *nAngVelZ, 
                                 int *bMoreToCreate);
								
#endif	//#ifndef __EXTERNAL_FACTORY_INTERFACE__

